package pers.qianyu.month_202012.date_20201225.dp_bag2;

import org.junit.*;

/**
 * 749. 约翰的后花园
 * https://www.lintcode.com/problem/johns-backyard-garden/description
 * - 简单动态规划
 *
 * @author mizzle rain
 * @date 2020-12-25 14:55
 */
public class IsBuild {
    /**
     * @param x: the wall's height
     * @return: YES or NO
     */
    public String isBuild(int x) {
        if (x < 3) {
            return "NO";
        }
        boolean[] dp = new boolean[x + 1];
        dp[0] = true;
        for (int i = 3; i <= x; i++) {
            if (i < 7) {
                dp[i] = dp[i - 3];
            } else {
                dp[i] = dp[i - 3] | dp[i - 7];
            }
        }
        return dp[x] ? "YES" : "NO";
    }

    public static void main(String[] args) {
        String result = new IsBuild().isBuild(10);
        Assert.assertEquals(result, "YES");
    }
}
